<template>
  <div>
    <el-descriptions
      :title="title"
      :column="column"
      :size="size"
      :border="border"
      :contentStyle="contentStyle"
      :labelStyle="labelStyle"
    >
      <template slot="title">
        <slot name="left_top"></slot>
      </template>
      <template slot="extra">
        <slot name="right_top"></slot>
      </template>
      <template v-for="item in list">
        <el-descriptions-item v-if="item.slot" :key="item.label" :label="item.label">
          <slot :name="item.slotName" :data="item"></slot>
        </el-descriptions-item>
        <el-descriptions-item v-else :key="item.label" :label="item.label">{{
          item.value
        }}</el-descriptions-item>
      </template>
    </el-descriptions>

    <slot name="bottom"></slot>
  </div>
</template>

<script>
export default {
  name: "descriptions",
  data() {
    return {
      contentStyle: {
        "text-align": "center", //文本居中
        "min-width": "100px", //最小宽度
        "word-break": "break-all", //过长时自动换行
      },
      labelStyle: {
        "color": "black",
        "text-align": "center",
        "font-weight": "400",
        "height": "40px",
        "min-width": "110px",
        "word-break": "keep-all",
        "background-color":'#fff'
      },
    };
  },
  props: {
    list: {
      type: Array,
      required: true,
    },
    title: {
      type: String,
      default: "描述列表",
    },
    size: {
      type: String,
      default: "",
    },
    border: {
      type: Boolean,
      default: false,
    },
    column: {
      type: Number,
      default: 2,
    },
  },
};
</script>

<style>
</style>